<%--用户个人发布的笔记界面--%>
<%@ page import="dao.ImplementNote" %>
<%@ page import="pojo.Note" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="dao.ImplementUser" %><%--
  Created by IntelliJ IDEA.
  User: tangms
  Date: 2022/4/2
  Time: 8:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<style>
    *{
        margin: 0px;
        padding: 0px;
        box-sizing: border-box;
    }
    .bag{
        width: 500px;
        height:110px;
        border: 8px solid #EEEEEE;
        margin: auto;
        padding: 15px;

    }
    .choice{
        border: 1px solid lightskyblue;
        margin: auto;
    }
    .button{
        border: 1px solid dodgerblue;
        background-color: dodgerblue;
        align-content: center;
    }
    #firstPage{
        float: left;
        margin: auto;
    }
    #view{
        float: right;
        margin: auto;
    }
    #game{
        margin-left: 15px;
        margin-right: 20px;
    }
    #food{
        margin-left: 15px;
        margin-right: 20px;
    }
    #cartoon{
        margin-left: 15px;
        margin-right: 10px;
    }
    .end{
        float: right;
        margin-top: 10px;
    }
    .title_left{
        margin-left: 420px;
    }
    .delete{
        margin-left: 790px;
    }
    .content_left{
        border:1px solid black;
        width: 440px;
        margin-left: 420px;
        height: 100px;
        margin-bottom: 20px;
    }
    .type{
        margin-left: 420px;
    }
</style>
<script>
    function deleteNote(id){
        if(confirm("您确定删除吗？")){
            location.href="${pageContext.request.contextPath}/deleteNoteServlet?id="+id;
        }
    }
</script>
<body>
<%
    String usename= (String) session.getAttribute("usename");
    ImplementNote implementNote=new ImplementNote();
    ArrayList<Note> userallnotes=new ArrayList<Note>();
    userallnotes=implementNote.userallnote(usename);
    request.setAttribute("userallnotes",userallnotes);
    ImplementUser implementUser=new ImplementUser();
    boolean flag=implementUser.findPower(usename);
    request.setAttribute("flag",flag);
%>
<form >
    <table>
        <div class="bag">
            <div class="choice">
                <h2 align="center">个人笔记</h2>
                <a href="allAreas.jsp" class="button" type="submit" id="firstPage">全部</a>
                <a href="gameArea.jsp" class="button" type="submit" id="game">游戏区</a>
                <a href="petArea.jsp" class="button" type="submit" id="pet">萌宠区</a>
                <a href="foodArea.jsp" class="button" type="submit" id="food">美食区</a>
                <a href="sportArea.jsp" class="button" type="submit" id="sport">体育区</a>
                <a href="cartoonArea.jsp" class="button" type="submit" id="cartoon">动漫区</a>
                <a href="viewArea.jsp" class="button" type="submit" id="view">风景区</a><hr><br>
                <div class="end">
                    <a href="allAreas.jsp" type="submit" id="note">返回首页</a>
                    <c:if test="${flag==true}">
                    <a href="${pageContext.request.contextPath}/addNote.jsp" type="submit" id="addNote">添加笔记</a>
                    </c:if>
                    <c:if test="${flag==true}">
                        <a href="${pageContext.request.contextPath}/user_checkednote.jsp" type="submit" id="checkednote">待审核笔记</a>
                    </c:if>
                    <a href="${pageContext.request.contextPath}/userInformation.jsp" type="submit" id="infomation">个人中心</a>
                </div>
            </div>
        </div>
    </table>
</form>
<c:forEach items="${userallnotes}" var="note" varStatus="s">
    <c:if test="${note.style==1}">
    <form>
        <table>
            <tr>
                <td>
                    <h5 class="title_left" name="title">${note.title}</h5>
                    <h5 class="type">${note.type}</h5>
                    <a href="javascript:deleteNote(${note.id});" class="delete" type="submit">删除</a>
                    <a href="findNoteServlet?id=${note.id}" type="submit" class="update" >修改</a>
                    <c:if test="submit.onclick"></c:if>
                    <p class="content_left" name="content">${note.content}</p>
                </td>
            </tr>
        </table>
    </form>
    </c:if>
</c:forEach>
</body>
</html>
